package net.lab1024.sa.admin.module.business.file.controller;

import net.lab1024.sa.admin.module.business.file.domain.form.add.FiletypeAddForm;
import net.lab1024.sa.admin.module.business.file.domain.form.query.FiletypeQueryForm;
import net.lab1024.sa.admin.module.business.file.domain.form.update.FiletypeUpdateForm;
import net.lab1024.sa.admin.module.business.file.domain.vo.FiletypeVO;
import net.lab1024.sa.admin.module.business.file.service.FiletypeService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 文件分类 Controller
 *
 * @Author AKITA
 * @Date 2025-07-04 14:25:49
 * @Copyright AKITA
 */

@RestController
@Tag(name = "文件分类")
public class FiletypeController {

    @Resource
    private FiletypeService filesService;

    @PostMapping("/filetype/queryPage")
    public ResponseDTO<PageResult<FiletypeVO>> queryPage(@RequestBody @Valid FiletypeQueryForm queryForm) {
        return ResponseDTO.ok(filesService.queryPage(queryForm));
    }


    @PostMapping("/filetype/add")
    public ResponseDTO<String> add(@RequestBody @Valid FiletypeAddForm addForm) {
        return filesService.add(addForm);
    }


    @PostMapping("/filetype/update")
    public ResponseDTO<String> update(@RequestBody @Valid FiletypeUpdateForm updateForm) {
        return filesService.update(updateForm);
    }


    @PostMapping("/filetype/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return filesService.batchDelete(idList);
    }


    @GetMapping("/filetype/delete/{docEntry}")
    public ResponseDTO<String> batchDelete(@PathVariable Long docEntry) {
        return filesService.delete(docEntry);
    }

    @GetMapping("/filetype/listAll")
    public ResponseDTO<List<FiletypeVO>> listAll() {
        return filesService.listAll();
    }

    @GetMapping("/filetype/listTree")
    public ResponseDTO<List<FiletypeVO>> listTree() {
        return filesService.listTree();
    }
}
